namespace designpatternsplusplus.decorator.DomainEntities
{
    #region

    using System;
    using designpatternsplus.contracts;

    #endregion

    /// <summary>
    /// 
    /// </summary>
    public sealed class MarketStaffMember : IMarketStaffMember
    {
        readonly long _employeeID;
        JobLevel _jobJobLevel = JobLevel.Unknown;

        MarketStaffMember(long EmployeeID)
        {
            _employeeID = EmployeeID;
            SetBadgeFromId(this);
        }


        /// <summary>
        /// Gets the job level.
        /// </summary>
        /// <value>The job level.</value>
        public JobLevel JobLevel
        {
            get { return _jobJobLevel; }
            set { _jobJobLevel = value; }
        }

        ///<summary>
        ///</summary>
        public string LastName { get; internal set; }

        /// <summary>
        /// Gets or sets the first name.
        /// </summary>
        /// <value>The first name.</value>
        public string FirstName { get; internal set; }

        /// <summary>
        /// Gets the employee ID.
        /// </summary>
        /// <value>The employee ID.</value>
        public long EmployeeID
        {
            get { return _employeeID; }
        }

        static void SetBadgeFromId(MarketStaffMember whoToSet)
        {
            whoToSet.FirstName = "Jane";
            whoToSet.LastName = "Doe";
            whoToSet.JobLevel = JobLevel.Unknown;
        }

        /// <summary>
        /// Asks the specified resolve question please.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="resolveQuestionPlease">The resolve question please.</param>
        /// <returns></returns>
        public T AskQuestion<T>(Func<T> resolveQuestionPlease)
        {
            return resolveQuestionPlease();
        }

        /// <summary>
        /// Opens the store.
        /// </summary>
        public static CoolCrapMarket OpenStore()
        {
            //if (MarketRules.OpenStorePermission(_jobJobLevel).Compile()())
            //    marketOpened = new CoolCrapMarket(this, ShoppingCartSection.Setup(4));
            //else
            //{
            //    throw new InvalidOperationException("You lack that privlidge");
            //}

            var manager = Lookup(Guid.NewGuid().GetHashCode());

            var marketOpened = new CoolCrapMarket(ShoppingCartSection.Setup(5))
                               {
                                   Manager = manager,
                               };
            return marketOpened;


            //PerermissionsSet.OpenStorePermission(_jobJobLevel))
            //    throw new InvalidOperationException("You do not have rights to open the store");
        }

        static MarketStaffMember Lookup(int i)
        {
            return new MarketStaffMember(i);
        }
    }
}